home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / removeFromCharacter.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.4 KB  |  73 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //    Alias|Wavefront Script File
  19. //    MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //    Creation Date:  27 November 1998
  22. //    Author:         mt
  23. //
  24. //  Procedure Name:
  25. //      removeFromCharacter
  26. //
  27. //  Description:
  28. //      remove the given list of items from the given character.  If a node is
  29. //      is included in the items passed in, then all attributes of that node
  30. //      will be removed from the character.  This procedure will not search 
  31. //      sub characters.
  32. //
  33. //  Input Arguments:
  34. //      $character - character to remove from 
  35. //      $items[]   - items to remove 
  36. //
  37. //  Return Value:
  38. //      None.
  39. //
  40. global proc removeFromCharacter( string $character, string $items[] )
  41. {
  42.     if (nodeType($character) != "character") {
  43.         error("A character in the list must be highlighted.");
  44.         return;
  45.     }
  46.  
  47.     string $removeList[];
  48.     for ( $item in $items ) {
  49.         if ( ( `gmatch $item "*.*"` ) || 
  50.              ( "character" == `nodeType $item` ) ) {
  51.             // Item is a specific attribute, or it is another character.  
  52.             // Try to remove it as is
  53.             //
  54.             $removeList[size($removeList)] = $item;
  55.         } else {
  56.             // We have a node.  We should remove any attributes of the
  57.             // node from the character
  58.             //
  59.             string $setContents[] = `character -query $character`;
  60.             $matchString = ( $item + ".*" );
  61.             for ( $setItem in $setContents ) {
  62.                 if ( `gmatch $setItem $matchString` ) {
  63.                     // We have an attribute of the given node
  64.                     // in the character
  65.                     //
  66.                     $removeList[size($removeList)] = $setItem;
  67.                 }
  68.             }
  69.         }
  70.     }
  71.     character -remove $character $removeList;
  72. }
  73.